<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    
</body>
<script src="http://libs.baidu.com/jquery/2.0.0/jquery.min.js"></script>
<script>

    //写一个生成器的主函数
    function* main(){
        let res = yield  request("http://39.104.16.173:8081/area/hot");
        // console.log(res);
        let id = res.body[0].value;
        let res2 = yield request2("http://39.104.16.173:8081/area/hot",id);
        // console.log(res2);
    }

    let it = main();
    it.next() 

    //封装一个ajax请求函数
    function request(url){
        $.ajax({
            url,
            type: "get",
            success: function (res) {
                it.next(res);
            }
        });
    }
    //请求地区
    // function request2(url,id){
    //     $.ajax({
    //         type: "get",
    //         url,
    //         data:{
    //             id:id
    //         },
    //         success: function (res2) {
    //             it.next(res2)
    //         }
    //     });
    // }

</script>
</html>